package com.ychen.goods.controller;

import com.ychen.commons.annotation.Login;
import com.ychen.commons.entity.goods.GoodsEntity;
import com.ychen.commons.utils.R;
import com.ychen.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @GetMapping("/listRecommendGoods")
    public R getRecommendGoods(@RequestParam Map<String, Object> params) {
        Long userId = 0L;
        List<GoodsEntity> recommendGoods = goodsService.getRecommendGoods(userId, params);
        System.out.println("ws");
        return R.ok().put("data", recommendGoods);
    }

    @Login
    @PostMapping("/testToken")
    public R testToken(@RequestParam Map<String, Object> params,@RequestAttribute("userId") Long userId) {

        System.out.println("userId = " +userId);
        return R.ok().put("data", params);
    }

}
